<script type="text/javascript">
function save(){
	var options = {
		beforeSubmit:  showRequest,  // pre-submit callback 
		success:       showResponse  // post-submit callback 
    };
	$('#frmManagement').ajaxSubmit(options);
}

function showRequest(formData, jqForm, options) {
	var form = jqForm[0];
}

function showResponse(responseText, statusText, xhr, $form) {
	if(responseText=='success'){
		location.href=root+"admincp/"+module+"/#/save";
	} else if(responseText == 'error-user-exists' ){
		alert('Không được nhập trùng username');
		document.getElementById('usernameAdmincp').focus()
		return;
	} else if(responseText == 'error-fb-exists' ){
		alert('Không được nhập trùng facebook ID');
		document.getElementById('facebookIDAdmincp').focus()
		return;
	} else if(responseText == 'error-user-empty'){
		alert('Chưa nhập username');
		document.getElementById('usernameAdmincp').focus()
		return;
	} else if(responseText == 'error-email-exists'){
		alert('Không được trùng Email');
		document.getElementById('emailAdmincp').focus()
		return;
	}
}
</script>

<div class="table">
	<div class="head_table"><div class="head_title_edit"><?=$module?></div></div>
	<div class="clearAll"></div>
	<form id="frmManagement" action="<?=PATH_URL.'admincp/'.$module.'/add/'?>" method="post" enctype="multipart/form-data">
	<input type="hidden" value="<?=$id?>" name="hiddenIdAdmincp" />
	<div class="row_text_field_first">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Status:</td>
				<td class="right_text_field"><input <?php if(isset($result->status)){ if($result->status==1){ ?>checked="checked"<?php }}else{ ?>checked="checked"<?php } ?> type="checkbox" class="custom_chk" name="statusAdmincp" /></td>
			</tr>
		</table>
	</div>
	
	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Avatar:</td>
				<td class="right_text_field"><input type="file" name="fileAdmincp" /><?php if(isset($result->avatar)){ if($result->avatar!=''){ ?> - <a class="fancyboxClick" href="<?=PATH_URL.'static/uploads/users/avatar/'.$result->avatar?>">Review</a><?php }} ?></td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Username:</td>
				<td class="right_text_field"><input id="usernameAdmincp" name="usernameAdmincp" value="<?php if(isset($result->username)) { print $result->username; }else{ print '';} ?>" type="text" /></td>
			</tr>
		</table>
	</div>
	
	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Email:</td>
				<td class="right_text_field"><input id="emailAdmincp" name="emailAdmincp" value="<?php if(isset($result->email)) { print $result->email; }else{ print '';} ?>" type="text" /></td>
			</tr>
		</table>
	</div>
	
	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Full name:</td>
				<td class="right_text_field"><input name="fullnameAdmincp" value="<?php if(isset($result->fullname)) { print $result->fullname; }else{ print '';} ?>" type="text" /></td>
			</tr>
		</table>
	</div>

	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">Facebook ID:</td>
				<td class="right_text_field"><input id="facebookIDAdmincp" name="facebookIDAdmincp" value="<?php if(isset($result->fb_id)) { print $result->fb_id; }else{ print '';} ?>" type="text" /></td>
			</tr>
		</table>
	</div>
	
	<div class="row_text_field">
		<table cellspacing="0" cellpadding="0" border="0" width="100%">
			<tr>
				<td class="left_text_field">IP:</td>
				<td class="right_text_field"><input name="ipAdmincp" value="<?php if(isset($result->ip)) { print $result->ip; }else{ print '';} ?>" type="text" /></td>
			</tr>
		</table>
	</div>
	</form>
</div>